<%@ page contentType="text/html; charset=utf-8"%>

<div class="left-sidebar">
    <!-- 用户信息 -->
    <div class="tpl-sidebar-user-panel">
        <div class="tpl-user-panel-slide-toggleable">


            <form id="uploadAvatarForm" enctype="multipart/form-data">
                <div class="am-form-group am-form-file">
                    <div class="tpl-user-panel-profile-picture">
                        <img id="avatarImg" src="/user/showAvatar.do" alt="">
                    </div>

                    <input id="doc-form-file" type="file" name="avatarFile" multiple="" onchange="uploadAvatar()">
                </div>
            </form>

            <a href="javascript:;" class="tpl-user-panel-action-link">
                <span class="am-icon-pencil"></span> 账号设置
            </a>
        </div>
    </div>


    <!-- 菜单 -->
    <ul class="sidebar-nav">

        <li class="sidebar-nav-link">
            <a id="homeA" href="/user/toHome.do">
                <i class="am-icon-home sidebar-nav-link-logo"></i> 首页
            </a>
        </li>
        <li class="sidebar-nav-link">
            <a id="openaccountA" href="/user/toOpenAccount.do">
                <i class="am-icon-wpforms sidebar-nav-link-logo"></i> 开户
            </a>
        </li>
        <li class="sidebar-nav-link">
            <a href="/user/xxx.do">
                <i class="am-icon-wpforms sidebar-nav-link-logo"></i> 取款
            </a>
        </li>
        <li class="sidebar-nav-link">
            <a id="depositA" href="/user/toDeposit.do">
                <i class="am-icon-wpforms sidebar-nav-link-logo"></i> 存款

            </a>
        </li>
        <li class="sidebar-nav-link">
            <a id="transferA" href="/user/toTransfer.do">
                <i class="am-icon-wpforms sidebar-nav-link-logo"></i> 转账

            </a>
        </li>

        <li class="sidebar-nav-link">
            <a id="flowA" href="/user/toFlow.do">
                <i class="am-icon-bar-chart sidebar-nav-link-logo"></i> 流水
            </a>
        </li>

        <li class="sidebar-nav-link">
            <a id="emailA" href="/user/toBindEmail.do">
                <i class="am-icon-bar-chart sidebar-nav-link-logo"></i> 绑定邮箱
            </a>
        </li>

    </ul>
</div>

<script>
    function uploadAvatar() {
        $('#uploadAvatarForm').ajaxSubmit({
            url : '/user/uploadAvatar.do',
            type : 'post',
            success: function (result) {

                if (result.code != 1000) {
                    alert(result.message);
                    return;
                }

                //为了不走缓存，故意将请求参数设置为当前时间毫秒数，这样浏览器每次发现请求地址都是不同的，也就不走缓存了。
                $('#avatarImg').attr('src', '/user/showAvatar.do?xxx=' + new Date().getTime());
            }
        })
    }
</script>